home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / setEdBookmarkEditor.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.7 KB  |  258 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 27, 1997
  22. //  Author:  db
  23. //
  24. //  Description:
  25. //      This script creates a bookmark editor for the set editor
  26. //
  27.  
  28. global proc setEdBookmarkMakeMenuBar(string $setEd)
  29. {
  30.     menu -l "Edit" -aob true;
  31.         menuItem 
  32.             -l "Add Bookmark"
  33.             -command ("setEdBookmarkAddCallback " + $setEd + " later");
  34.         menuItem -optionBox true -l "Add Bookmark Option Box"
  35.             -command ("setEdBookmarkAddCallback " + $setEd + " first");
  36.         menuItem 
  37.             -l "Delete Bookmark" 
  38.             -command ("setEdBookmarkDeleteCallback " + $setEd);
  39.         menuItem 
  40.             -l "Rename Bookmark..." 
  41.             -command ("setEdBookmarkRenameCallback " + $setEd);
  42. }
  43.  
  44.  
  45. global proc setEdBookmarkUpdate(string $setEd) 
  46. {
  47.     // Unique names for the widgets for this
  48.     // instance of the bookmark editor
  49.     string $bmeWindow = ($setEd + "BMEDWindow");
  50.     string $bmeForm = ($setEd + "BMEForm");
  51.     string $bmeListForm = ($setEd + "BMEListForm");
  52.     string $bmeTextList = ($setEd + "BMETextList");
  53.  
  54.     if (`window -exists $bmeWindow`)
  55.     {
  56.         setParent ($bmeWindow + "|" + $bmeForm + "|" + $bmeListForm);
  57.  
  58.         if (`textScrollList -exists $bmeTextList`)
  59.         {
  60.             deleteUI $bmeTextList;
  61.         }
  62.  
  63.         formLayout -e -visible false $bmeListForm;
  64.  
  65.         textScrollList -height 100 
  66.             -allowMultiSelection no 
  67.             -allowAutomaticSelection yes 
  68.             $bmeTextList;
  69.  
  70.         formLayout -e
  71.             -attachForm $bmeTextList top 0 
  72.             -attachForm $bmeTextList left 0 
  73.             -attachForm $bmeTextList bottom 0
  74.             -attachForm $bmeTextList right 0 
  75.             $bmeListForm;
  76.  
  77.         textScrollList -e -selectCommand ("setEdBookmarkSelectCallback " + $setEd) $bmeTextList;
  78.         textScrollList -e -doubleClickCommand ("setEdBookmarkRenameCallback " + $setEd) $bmeTextList;
  79.         textScrollList -e -deleteKeyCommand ("setEdBookmarkDeleteCallback " + $setEd) $bmeTextList;
  80.  
  81.         string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
  82.         for ($bookmark in $bookmarks)
  83.         {
  84.             textScrollList -e -a $bookmark $bmeTextList;
  85.         }
  86.  
  87.         formLayout -e -visible true $bmeListForm;
  88.  
  89.         setParent ..;
  90.     }
  91. }
  92.  
  93. global proc setEdBookmarkCreateUI(string $setEd)
  94. {
  95.     // Unique names for the widgets for this
  96.     // instance of the bookmark editor
  97.     string $bmeWindow = ($setEd + "BMEDWindow");
  98.     string $bmeForm = ($setEd + "BMEForm");
  99.     string $bmeListForm = ($setEd + "BMEListForm");
  100.     string $bmeButtonForm = ($setEd + "BMEButtonForm");
  101.     string $bmeAddButton = ($setEd + "BMEAddButton");
  102.  
  103.     // Create a new window
  104.     window
  105.         -title "Bookmarks"
  106.         -width 140 -height 400
  107.         -menuBar true
  108.         -minimizeButton true
  109.         -maximizeButton false
  110.         $bmeWindow;
  111.  
  112.     setEdBookmarkMakeMenuBar $setEd;
  113.  
  114.     formLayout $bmeForm;
  115.     formLayout $bmeListForm;;
  116.     setParent ..;
  117.     formLayout -height 30 $bmeButtonForm;
  118.  
  119.     button -l "Add Bookmark" -c ("setEdBookmarkAddCallback " + $setEd + " later") $bmeAddButton;
  120.     
  121.     formLayout -e 
  122.         -attachForm $bmeListForm right 0
  123.         -attachForm $bmeListForm left 0
  124.         -attachForm $bmeListForm top 0
  125.         $bmeForm;
  126.     
  127.     formLayout -e
  128.         -attachForm $bmeButtonForm right 0
  129.         -attachForm $bmeButtonForm left 0
  130.         -attachForm $bmeButtonForm bottom 0
  131.         $bmeForm;
  132.  
  133.     formLayout -e
  134.         -attachControl $bmeListForm bottom 0 $bmeButtonForm
  135.         $bmeForm;
  136.     
  137.     formLayout -e
  138.         -af $bmeAddButton top 0 
  139.         -af $bmeAddButton left 0 
  140.         -af $bmeAddButton bottom 0
  141.         -af $bmeAddButton right 0 
  142.         $bmeButtonForm;
  143.  
  144.     setEdBookmarkUpdate $setEd;
  145.     showWindow $bmeWindow;
  146. }
  147.  
  148.  
  149. global proc string getSelectedBookmark(string $setEd)
  150. {
  151.     // Unique name for the text scroll list
  152.     string $bmeTextList = ($setEd + "BMETextList");
  153.  
  154.     string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
  155.     int $item[1] = `textScrollList -q -selectIndexedItem $bmeTextList`;
  156.     string $bookmarkName = $bookmarks[$item[0]-1];
  157.  
  158.     return $bookmarkName;
  159. }
  160.  
  161. global proc setEdBookmarkSelectCallback(string $setEd)
  162. //
  163. // Callback for selecting set editor bookmarks.
  164. //
  165. {
  166.     string $bookmarkName = getSelectedBookmark($setEd);
  167.     setEditor -edit -useBookmark $bookmarkName $setEd;
  168. }
  169.  
  170.  
  171. global proc setEdBookmarkDeleteCallback(string $setEd)
  172. //
  173. // Callback for deleting set editor bookmarks.
  174. //
  175. {
  176.     string $bookmarkName = getSelectedBookmark($setEd);
  177.     delete $bookmarkName;
  178.     setEdBookmarkUpdate $setEd;
  179. }
  180.  
  181.  
  182. global proc setEdBookmarkRenameMenuCallback(string $setEd, string $oldBookmarkName)
  183. //
  184. // Callback for renaming set editor bookmarks.
  185. // (invoked from the menu option box)
  186. //
  187. {
  188.     string $result = `promptDialog
  189.         -title "Rename Bookmark"
  190.         -message "Rename Bookmark:"
  191.         -text $oldBookmarkName
  192.         -defaultButton "OK"
  193.         -button "OK" 
  194.         -button "Cancel"`;
  195.     if ($result == "OK")
  196.     {
  197.         string $newBookmarkName = `promptDialog -q -tx`;
  198.         rename $oldBookmarkName $newBookmarkName;
  199.         setEdBookmarkUpdate $setEd;
  200.     }
  201. }
  202.  
  203. global proc setEdBookmarkRenameCallback(string $setEd)
  204. //
  205. // Callback for renaming set editor bookmarks.
  206. // (invoked by double clicking in editor)
  207. //
  208. {
  209.     string $oldBookmarkName = getSelectedBookmark($setEd);
  210.     setEdBookmarkRenameMenuCallback($setEd, $oldBookmarkName);
  211. }
  212.  
  213.  
  214. global proc setEdBookmarkAddCallback(string $setEd, string $renameWhen)
  215. //
  216. // Callback for adding set editor bookmarks.
  217. //
  218. {
  219.     if ($renameWhen == "first")
  220.     {
  221.         string $result = `promptDialog
  222.             -title "Name Bookmark"
  223.             -message "Name Bookmark:"
  224.             -text "Bookmark Name"
  225.             -defaultButton "OK"
  226.             -button "OK" 
  227.             -button "Cancel"`;
  228.         if ($result == "OK")
  229.         {
  230.             string $newBookmarkName = `promptDialog -q -tx`;
  231.             setEditor -edit -createBookmark $newBookmarkName $setEd;
  232.             setEdBookmarkUpdate $setEd;
  233.         }
  234.     } else
  235.     {
  236.         setEditor -edit -createBookmark bookmark $setEd;
  237.         setEdBookmarkUpdate $setEd;
  238.     }
  239. }
  240.  
  241. global proc setEdBookmarkEditor(string $setEd)
  242. {
  243.     // Unique name for the window
  244.     string $bmeWindow = ($setEd + "BMEDWindow");
  245.  
  246.     if (`window -exists $bmeWindow`)
  247.     {
  248.         showWindow $bmeWindow;
  249.         setEdBookmarkUpdate $setEd;
  250.     }
  251.     else
  252.     {
  253.         setEdBookmarkCreateUI $setEd;
  254.     }
  255. }
  256.  
  257.  
  258.